package fun.hijklmn.magic.common.utils;

import fun.hijklmn.magic.common.enums.ResponseCodeEnum;
import fun.hijklmn.magic.common.vo.resp.ResultVO;

/**
 * @Description
 * @Author fs
 * @Date 2021/5/6 10:12
 * @Version 0.0.1-SNAPSHOT
 **/
public class ResultVOUtil {

    public static ResultVO success(Object object) {
        ResultVO resultVO = new ResultVO();
        resultVO.setData(object);
        resultVO.setCode(ResponseCodeEnum.SUCCESS.code());
        resultVO.setMessage(ResponseCodeEnum.SUCCESS.message());
        return resultVO;
    }

    public static ResultVO success(Object object, String message) {
        ResultVO resultVO = new ResultVO();
        resultVO.setData(object);
        resultVO.setCode(ResponseCodeEnum.SUCCESS.code());
        resultVO.setMessage(message);
        return resultVO;
    }

    public static ResultVO success() {
        return success(null);
    }

    public static ResultVO error(Integer code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMessage(msg);
        return resultVO;
    }

    public static ResultVO error(Object object,Integer code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setData(object);
        resultVO.setCode(code);
        resultVO.setMessage(msg);
        return resultVO;
    }

    public static ResultVO parse(ResponseCodeEnum responseCodeEnum) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(responseCodeEnum.code());
        resultVO.setMessage(responseCodeEnum.message());
        return resultVO;
    }

    public static ResultVO parse(ResponseCodeEnum responseCodeEnum, String message) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(responseCodeEnum.code());
        resultVO.setMessage(message);
        return resultVO;
    }

}
